﻿Imports System.Runtime.CompilerServices

Public Module StringExtensions

    <Extension()> _
    Function ToTitle(ByVal Text As String) As String
        Text = " " & Text.ToLower
        For Each c In " /();:.-"
            Dim Pos As Integer = 0
            Do
                Pos = InStr(Pos + 1, Text, c)
                If Pos = 0 Then Exit Do
                If Pos = Text.Length Then Exit Do
                Mid(Text, Pos + 1, 1) = Mid(Text, Pos + 1, 1).ToUpper
            Loop
        Next
        Return Text.Trim
    End Function

	<Extension()> _
	Function ClipUpto(ByRef Text As String, Expr As String) As String
		Dim Pos = InStr(Text, Expr)
		Dim Temp = Mid(Text, 1, Pos - 1)
		Text = Mid(Text, Pos + Len(Expr))
		Return Temp
	End Function

End Module
